<?php
error_reporting(E_ALL ^ E_NOTICE);

set_time_limit(0);
date_default_timezone_set("PRC"); //timezone

$db=mysql_connect("192.168.1.246","root","root"); 
mysql_select_db('faithwar',$db); 

$db2=mysql_connect('192.168.0.17','root','root'); 
mysql_select_db('faithwar',$db2); 

$db3=mysql_connect("192.168.1.246:5029","root","root"); 
mysql_select_db('faithwar',$db3); 

$dateTime = date("Y-m-d",strtotime("-1 day"));
#$dateTime = date("Y-m-d");

$logdate =  mysql_query("SELECT DISTINCT date FROM `faithwar` where date = '$dateTime'",$db);

while($everylogdate = mysql_fetch_array($logdate))
{
      //totalDayNewusers 每日新注册 DISTINCT
    $totalDayNewusers_query = mysql_query("SELECT count(DISTINCT deviceid)  FROM  faithwar  where action =3 and date ='$everylogdate[date]'",$db3);
    $totalDayNewusers = mysql_fetch_array($totalDayNewusers_query);
     //DayActivePesonrNum  每日活跃人数  //  日均TodaydayTotalTime 活跃人数 今日的
    $dayActivePesonrNum_query = mysql_query("SELECT count(DISTINCT deviceid)  FROM faithwar  where firstlogin <'$everylogdate[date]'  and action =1 and date ='$everylogdate[date]'",$db3);
    $dayActivePesonrNum = mysql_fetch_array($dayActivePesonrNum_query);
     //dayActivePesonrTime 每日活跃人次
    $dayActivePesonrTime_query = mysql_query("SELECT sum(action =1) FROM faithwar WHERE   date ='$everylogdate[date]' and firstlogin <'$everylogdate[date]'",$db3);
    $dayActivePesonrTime = mysql_fetch_array($dayActivePesonrTime_query);
     //totalDayPlayTime 每日游戏打开次数【总】 
    $totalDayPlayTime_query = mysql_query("SELECT sum(action =1) FROM faithwar WHERE  date ='$everylogdate[date]'",$db3);
    $totalDayPlayTime = mysql_fetch_array($totalDayPlayTime_query);
     //DayPesonrNum  每日人数  
    $DayPesonrNum_query = mysql_query("SELECT count(DISTINCT deviceid)  FROM faithwar  where  action =1 and date ='$everylogdate[date]'",$db3);
    $DayPesonrNum = mysql_fetch_array($DayPesonrNum_query);
     //dayPlayTime 每日人均打开次数 
    $dayPlayTime_query = mysql_query("SELECT '$totalDayPlayTime[0]'/'$DayPesonrNum[0]'",$db3);
    $dayPlayTime = mysql_fetch_array($dayPlayTime_query);
     //totaldayTotalTime 每日用户游戏时间【总】 
    $totaldayTotalTime_query = mysql_query("SELECT sum(dayTotalTime)  FROM faithwar WHERE  date ='$everylogdate[date]'",$db);
    $totaldayTotalTime = mysql_fetch_array($totaldayTotalTime_query);

    //dayTotalTime 每日人均游戏时间 
    $dayTotalTime_query = mysql_query("SELECT avg(dayTotalTime)  FROM faithwar WHERE  date ='$everylogdate[date]'",$db);
    $dayTotalTime = mysql_fetch_array($dayTotalTime_query);
     //newPayPesonrNum  每日新增付费人数
    $newPayPesonrNum_query = mysql_query("select A.deviceid  from (SELECT  DISTINCT deviceid FROM `faithwar` WHERE money >0  and 

        date 

        = DATE_SUB( 

        '$everylogdate[date]', INTERVAL 0
        DAY ) )A left join (SELECT  DISTINCT deviceid FROM `faithwar` WHERE 

        money >0  and date
        BETWEEN DATE_SUB( '$everylogdate[date]', INTERVAL 360
        DAY )
        AND DATE_SUB( '$everylogdate[date]', INTERVAL 1
        DAY )  )B on A.deviceid =B.deviceid  where B.deviceid  is null",$db3);
    $newPayPesonrNum = mysql_num_rows($newPayPesonrNum_query);

       //每日付费人数 PayPesonrNum
    $PayPesonrNum_query = mysql_query("SELECT  count(DISTINCT deviceid) FROM `faithwar`  where  date ='$everylogdate[date]' and money >0 ",$db3);
    $PayPesonrNum = mysql_fetch_array($PayPesonrNum_query);

      //每日付费次数 paytimes
    $paytimes_query = mysql_query("SELECT count(1)  FROM  tbiap  where  date ='$everylogdate[date]' and money >0  ",$db2);
    $paytimes = mysql_fetch_array($paytimes_query);
      //WeekNewPayPesonrNum 过去7日内新增注册用户数
    $WeekNewPayPesonrNum_query = mysql_query("SELECT count( DISTINCT deviceid )
        FROM faithwar
        WHERE date
        BETWEEN date_sub( '$everylogdate[date]', INTERVAL 7
        DAY )
        AND '$everylogdate[date]' and action =3",$db3);
     $WeekNewPayPesonrNum = mysql_fetch_array($WeekNewPayPesonrNum_query);
     //weekOneLandPesonrNum 过去7日内1次登录用户数
     $weekOneLandPesonrNum_query = mysql_query("  SELECT DISTINCT deviceid, date
        FROM faithwar
        WHERE date
        BETWEEN DATE_SUB( '$everylogdate[date]', INTERVAL 7
        DAY )
        AND DATE_SUB( '$everylogdate[date]', INTERVAL 1
        DAY ) and action =2
        GROUP BY deviceid
        HAVING count( 1 ) >0
        ",$db3);
     $weekOneLandPesonrNum = mysql_num_rows($weekOneLandPesonrNum_query);
     var_dump($weekOneLandPesonrNum);

     //weekActivePesonrNum   过去7日内2次登录用户数 每周活跃人数  SELECT * FROM faithwar   where DATE_SUB( date, INTERVAL 7 DAY ) <= date( '$everylogdate[date]' )
    $weekActivePesonrNum_query = mysql_query("  SELECT DISTINCT deviceid, date
        FROM faithwar
        WHERE  date
        BETWEEN DATE_SUB( '$everylogdate[date]', INTERVAL 7
        DAY )
        AND DATE_SUB( '$everylogdate[date]', INTERVAL 1
        DAY ) and action =2
        GROUP BY deviceid
        HAVING count( 1 ) >1
        ",$db3);
    //$weekActivePesonrNum_query = mysql_query("SELECT count(DISTINCT deviceid)  FROM  faithwar  where date_add(date,interval 2 day)   and DATE_SUB( date, INTERVAL 7 DAY ) <= date( '$everylogdate[date]' )  ");
    $weekActivePesonrNum = mysql_num_rows($weekActivePesonrNum_query);

    //weekLoyalPesonrNum  过去7日内3次登录用户数 每周忠诚用户人数
    $weekLoyalPesonrNum_query = mysql_query("SELECT DISTINCT deviceid, date
        FROM faithwar
        WHERE  date
        BETWEEN DATE_SUB( '$everylogdate[date]', INTERVAL 7
        DAY )
        AND DATE_SUB( '$everylogdate[date]', INTERVAL 1
        DAY ) and action =2
        GROUP BY deviceid
        HAVING count( 1 ) >2
        ",$db3);
   $weekLoyalPesonrNum = mysql_num_rows($weekLoyalPesonrNum_query);


    //weekCorePesonrNum   过去7日内4次用户数 每周核心用户人数
    $weekCorePesonrNum_query = mysql_query("SELECT DISTINCT deviceid, date
        FROM faithwar
        WHERE  date
        BETWEEN DATE_SUB( '$everylogdate[date]', INTERVAL 7
        DAY )
        AND DATE_SUB( '$everylogdate[date]', INTERVAL 1
        DAY ) and action =2
        GROUP BY deviceid
        HAVING count( 1 ) >3
        ",$db3);
    $weekCorePesonrNum = mysql_num_rows($weekCorePesonrNum_query);

        //weekFivePesonrNum   过去7日内5次用户数 
    $weekFivePesonrNum_query = mysql_query("SELECT DISTINCT deviceid, date
        FROM faithwar
        WHERE  date
        BETWEEN DATE_SUB( '$everylogdate[date]', INTERVAL 7
        DAY )
        AND DATE_SUB( '$everylogdate[date]', INTERVAL 1
        DAY ) and action =2
        GROUP BY deviceid
        HAVING count( 1 ) >4
        ",$db3);
    $weekFivePesonrNum = mysql_num_rows($weekFivePesonrNum_query);
    
     //MonthLandTwicePesonrNum 过去30日内2次登录用户数
        $MonthLandTwicePesonrNum_query = mysql_query("SELECT DISTINCT deviceid, date
        FROM faithwar
        WHERE  date
        BETWEEN DATE_SUB( '$everylogdate[date]', INTERVAL 30
        DAY )
        AND DATE_SUB( '$everylogdate[date]', INTERVAL 1
        DAY ) and action =2
        GROUP BY deviceid
        HAVING count( 1 ) >1 ",$db3);
     $MonthLandTwicePesonrNum = mysql_num_rows($MonthLandTwicePesonrNum_query);
       //NewFiveSeconds 新用户首次游戏时间 5秒 
    $NewFiveSeconds_query = mysql_query("SELECT count(1)  FROM  faithwar   where firstlogin ='$everylogdate[date]' and   dayTotalTime between 1 and 5",$db3);
    $NewFiveSeconds = mysql_fetch_array($NewFiveSeconds_query);
       //NewTenSeconds 新用户首次游戏时间 10秒 
    $NewTenSeconds_query = mysql_query("SELECT count(1)  FROM  faithwar   where firstlogin ='$everylogdate[date]' and   dayTotalTime between 6 and 10",$db3);
    $NewTenSeconds = mysql_fetch_array($NewTenSeconds_query);
       //NewTwentySeconds 新用户首次游戏时间 20秒 
    $NewTwentySeconds_query = mysql_query("SELECT count(1)  FROM  faithwar   where firstlogin ='$everylogdate[date]' and   dayTotalTime between 11 and 20",$db3);
    $NewTwentySeconds = mysql_fetch_array($NewTwentySeconds_query);
      //NewThirtySeconds 新用户首次游戏时间 30秒 
    $NewThirtySeconds_query = mysql_query("SELECT count(1)  FROM  faithwar   where firstlogin ='$everylogdate[date]' and   dayTotalTime between 21 and 30",$db3);
    $NewThirtySeconds = mysql_fetch_array($NewThirtySeconds_query);
      //NewSixtySeconds 新用户首次游戏时间 60秒 
    $NewSixtySeconds_query = mysql_query("SELECT count(1)  FROM  faithwar   where firstlogin ='$everylogdate[date]' and   dayTotalTime between 31 and 60",$db3);
    $NewSixtySeconds = mysql_fetch_array($NewSixtySeconds_query);
      //New120Seconds 新用户首次游戏时间 120秒 
    $New120Seconds_query = mysql_query("SELECT count(1)  FROM  faithwar   where firstlogin ='$everylogdate[date]' and   dayTotalTime between 61 and 120",$db3);
    $New120Seconds = mysql_fetch_array($New120Seconds_query);
      //New200Seconds 新用户首次游戏时间 200秒 
    $New200Seconds_query = mysql_query("SELECT count(1)  FROM  faithwar   where firstlogin ='$everylogdate[date]' and   dayTotalTime between 121 and 200",$db3);
    $New200Seconds = mysql_fetch_array($New200Seconds_query);
      //New300Seconds 新用户首次游戏时间 300秒 
    $New300Seconds_query = mysql_query("SELECT count(1)  FROM  faithwar   where firstlogin ='$everylogdate[date]' and   dayTotalTime between 201 and 300",$db3);
    $New300Seconds = mysql_fetch_array($New300Seconds_query);
      //New500Seconds 新用户首次游戏时间 500秒 
    $New500Seconds_query = mysql_query("SELECT count(1)  FROM  faithwar   where firstlogin ='$everylogdate[date]' and   dayTotalTime between 301 and 500",$db3);
    $New500Seconds = mysql_fetch_array($New500Seconds_query);
      //New700Seconds 新用户首次游戏时间 700秒 
    $New700Seconds_query = mysql_query("SELECT count(1)  FROM  faithwar   where firstlogin ='$everylogdate[date]' and   dayTotalTime between 501 and 700",$db3);
    $New700Seconds = mysql_fetch_array($New700Seconds_query);
      //New1000Seconds 新用户首次游戏时间 1000秒 
    $New1000Seconds_query = mysql_query("SELECT count(1)  FROM  faithwar   where firstlogin ='$everylogdate[date]' and   dayTotalTime between 701 and 1000",$db3);
    $New1000Seconds = mysql_fetch_array($New1000Seconds_query);
      //New1500Seconds 新用户首次游戏时间 1500秒 
    $New1500Seconds_query = mysql_query("SELECT count(1)  FROM  faithwar   where firstlogin ='$everylogdate[date]' and   dayTotalTime between 1001 and 1500",$db3);
    $New1500Seconds = mysql_fetch_array($New1500Seconds_query);
      //New2000Seconds 新用户首次游戏时间 2000秒 
    $New2000Seconds_query = mysql_query("SELECT count(1)  FROM  faithwar   where firstlogin ='$everylogdate[date]' and   dayTotalTime between 1501 and 5000",$db3);
    $New2000Seconds = mysql_fetch_array($New2000Seconds_query);

         //FiveSeconds 用户当日游戏时间 5秒 
    $FiveSeconds_query = mysql_query("SELECT count(DISTINCT deviceid)  FROM  faithwar   where date ='$everylogdate[date]' and   dayTotalTime between 1 and 5",$db3);
    $FiveSeconds = mysql_fetch_array($FiveSeconds_query);
         //TenSeconds 用户当日游戏时间 10秒 
    $TenSeconds_query = mysql_query("SELECT count(DISTINCT deviceid)  FROM  faithwar   where date ='$everylogdate[date]' and   dayTotalTime between 6 and 10",$db3);
    $TenSeconds = mysql_fetch_array($TenSeconds_query);
        //TwentySeconds 用户当日游戏时间 20秒 
    $TwentySeconds_query = mysql_query("SELECT count(DISTINCT deviceid)  FROM  faithwar   where date ='$everylogdate[date]' and   dayTotalTime between 11 and 20",$db3);
    $TwentySeconds = mysql_fetch_array($TwentySeconds_query);
         //ThirtySeconds 用户当日游戏时间 30秒 
    $ThirtySeconds_query = mysql_query("SELECT count(DISTINCT deviceid)  FROM  faithwar   where date ='$everylogdate[date]' and   dayTotalTime between 21 and 30",$db3);
    $ThirtySeconds = mysql_fetch_array($ThirtySeconds_query);
         //SixtySeconds 用户当日游戏时间 60秒 
    $SixtySeconds_query = mysql_query("SELECT count(DISTINCT deviceid)  FROM  faithwar   where date ='$everylogdate[date]' and   dayTotalTime between 31 and 60",$db3);
    $SixtySeconds = mysql_fetch_array($SixtySeconds_query);
         //120Seconds 用户当日游戏时间 120秒 
    $_120Seconds_query = mysql_query("SELECT count(DISTINCT deviceid)  FROM  faithwar   where date ='$everylogdate[date]' and   dayTotalTime between 61 and 120",$db3);
    $_120Seconds = mysql_fetch_array($_120Seconds_query);
         //200Seconds 用户当日游戏时间 200秒 
    $_200Seconds_query = mysql_query("SELECT count(DISTINCT deviceid)  FROM  faithwar   where date ='$everylogdate[date]' and   dayTotalTime between 121 and 200",$db3);
    $_200Seconds = mysql_fetch_array($_200Seconds_query);
         //300Seconds 用户当日游戏时间 300秒 
    $_300Seconds_query = mysql_query("SELECT count(DISTINCT deviceid)  FROM  faithwar   where date ='$everylogdate[date]' and   dayTotalTime between 201 and 300",$db3);
    $_300Seconds = mysql_fetch_array($_300Seconds_query);
         //500Seconds 用户当日游戏时间 500秒 
    $_500Seconds_query = mysql_query("SELECT count(DISTINCT deviceid)  FROM  faithwar   where date ='$everylogdate[date]' and   dayTotalTime between 301 and 500",$db3);
    $_500Seconds = mysql_fetch_array($_500Seconds_query);
         //700Seconds 用户当日游戏时间 700秒 
    $_700Seconds_query = mysql_query("SELECT count(DISTINCT deviceid)  FROM  faithwar   where date ='$everylogdate[date]' and   dayTotalTime between 501 and 700",$db3);
    $_700Seconds = mysql_fetch_array($_700Seconds_query);
         //1000Seconds 用户当日游戏时间 1000秒 
    $_1000Seconds_query = mysql_query("SELECT count(DISTINCT deviceid)  FROM  faithwar   where date ='$everylogdate[date]' and   dayTotalTime between 701 and 1000",$db3);
    $_1000Seconds = mysql_fetch_array($_1000Seconds_query);
         //1500Seconds 用户当日游戏时间 1500秒 
    $_1500Seconds_query = mysql_query("SELECT count(DISTINCT deviceid)  FROM  faithwar   where date ='$everylogdate[date]' and   dayTotalTime between 1001 and 1500",$db3);
    $_1500Seconds = mysql_fetch_array($_1500Seconds_query);
         //2000Seconds 用户当日游戏时间 2000秒 
    $_2000Seconds_query = mysql_query("SELECT count(DISTINCT deviceid)  FROM  faithwar   where date ='$everylogdate[date]' and   dayTotalTime between 1501 and 5000",$db3);
    $_2000Seconds = mysql_fetch_array($_2000Seconds_query);
   

 //ThreeDayWastageRate1 三天前的七天里登录的数量
    $ThreeDayWastageRate1_query = mysql_query("SELECT count(DISTINCT a.deviceid)
        FROM faithwar a
        WHERE a.date
        BETWEEN DATE_SUB( '$everylogdate[date]', INTERVAL 10
        DAY )
        AND DATE_SUB( '$everylogdate[date]', INTERVAL 4
        DAY ) ",$db3);
    $ThreeDayWastageRate1 = mysql_fetch_array($ThreeDayWastageRate1_query);

        //ThreeDayWastageRate2 三日流失率 连续3天未登录的数量
    $ThreeDayWastageRate2_query = mysql_query("SELECT count( DISTINCT a.deviceid )
        FROM (

        SELECT DISTINCT a.deviceid
        FROM faithwar a
        WHERE a.date
        BETWEEN DATE_SUB( '$everylogdate[date]', INTERVAL 10
        DAY )
        AND DATE_SUB( '$everylogdate[date]', INTERVAL 4
        DAY )
        )a
        LEFT JOIN (

        SELECT DISTINCT deviceid
        FROM faithwar
        WHERE date
        BETWEEN DATE_SUB( '$everylogdate[date]', INTERVAL 3
        DAY )
        AND DATE_SUB( '$everylogdate[date]', INTERVAL 1
        DAY )
        )b ON a.deviceid = b.deviceid
        WHERE b.deviceid IS NULL ",$db3);
    $ThreeDayWastageRate2 = mysql_fetch_array($ThreeDayWastageRate2_query);

    //ThreeDayWastageRate 三日流失率
    $ThreeDayWastageRate_query = mysql_query("SELECT concat(round( '$ThreeDayWastageRate2[0]'/ '$ThreeDayWastageRate1[0]' *100,2), '%' )",$db3);
    $ThreeDayWastageRate = mysql_fetch_array($ThreeDayWastageRate_query);

        //seventhDayWastageRate1 七天前的七日里登录的数量
    $seventhDayWastageRate_query1 = mysql_query("SELECT count(DISTINCT a.deviceid)
        FROM faithwar a
        WHERE a.date
        BETWEEN DATE_SUB( '$everylogdate[date]', INTERVAL 14
        DAY )
        AND DATE_SUB( '$everylogdate[date]', INTERVAL 8
        DAY ) ",$db3);
    $seventhDayWastageRate1 = mysql_fetch_array($seventhDayWastageRate_query1);
        //seventhDayWastageRate2 七日流失率 连续7天未登录的数量
    $seventhDayWastageRate_query2 = mysql_query("SELECT count( DISTINCT a.deviceid )
        FROM (

        SELECT DISTINCT a.deviceid
        FROM faithwar a
        WHERE a.date
        BETWEEN DATE_SUB( '$everylogdate[date]', INTERVAL 14
        DAY )
        AND DATE_SUB( '$everylogdate[date]', INTERVAL 8
        DAY )
        )a
        LEFT JOIN (

        SELECT DISTINCT deviceid
        FROM faithwar
        WHERE date
        BETWEEN DATE_SUB( '$everylogdate[date]', INTERVAL 7
        DAY )
        AND DATE_SUB( '$everylogdate[date]', INTERVAL 1
        DAY )
        )b ON a.deviceid = b.deviceid
        WHERE b.deviceid IS NULL",$db3);
    $seventhDayWastageRate2 = mysql_fetch_array($seventhDayWastageRate_query2);
        //seventhDayWastageRate 七日流失率
    $seventhDayWastageRate_query = mysql_query("SELECT concat(round( '$seventhDayWastageRate2[0]'/ '$seventhDayWastageRate1[0]' *100,2), '%' )",$db3);
    $seventhDayWastageRate = mysql_fetch_array($seventhDayWastageRate_query);

        //TwentyDayWastageRate1 二十日流失率 连续20天未登录的数量
    $TwentyDayWastageRate_query1 = mysql_query("SELECT count(DISTINCT a.deviceid)
        FROM faithwar a
        WHERE a.date
        BETWEEN DATE_SUB( '$everylogdate[date]', INTERVAL 27
        DAY )
        AND DATE_SUB( '$everylogdate[date]', INTERVAL 21
        DAY )",$db3);
    $TwentyDayWastageRate1 = mysql_fetch_array($TwentyDayWastageRate_query1);
        //TwentyDayWastageRate 二十日流失率 连续20天未登录的数量
    $TwentyDayWastageRate_query2 = mysql_query("SELECT count( DISTINCT a.deviceid )
        FROM (

        SELECT DISTINCT a.deviceid
        FROM faithwar a
        WHERE a.date
        BETWEEN DATE_SUB( '$everylogdate[date]', INTERVAL 27
        DAY )
        AND DATE_SUB( '$everylogdate[date]', INTERVAL 21
        DAY )
        )a
        LEFT JOIN (

        SELECT DISTINCT deviceid
        FROM faithwar
        WHERE date
        BETWEEN DATE_SUB( '$everylogdate[date]', INTERVAL 20
        DAY )
        AND DATE_SUB( '$everylogdate[date]', INTERVAL 1
        DAY )
        )b ON a.deviceid = b.deviceid
        WHERE b.deviceid IS NULL",$db3);
    $TwentyDayWastageRate2 = mysql_fetch_array($TwentyDayWastageRate_query2);
            //TwentyDayWastageRate 二十日流失率
    $TwentyDayWastageRate_query = mysql_query("SELECT concat(round( '$TwentyDayWastageRate2[0]'/ '$TwentyDayWastageRate1[0]' *100,2), '%' )",$db3);
    $TwentyDayWastageRate = mysql_fetch_array($TwentyDayWastageRate_query);
        //ThreeDayReflux 连续3天未登录的用户在第二天登陆过游戏
    $ThreeDayReflux_query = mysql_query("select DISTINCT A.deviceid from (select DISTINCT A.deviceid from faithwar A left join (select 

DISTINCT deviceid from  faithwar  where date between date_sub('$everylogdate[date]',interval 3 day) and 

date_sub('$everylogdate[date]',interval 1 day))B on A.deviceid =B.deviceid  where B.deviceid  is 

null) A inner join (select DISTINCT deviceid from  faithwar  where date ='$everylogdate[date]')B on 

A.deviceid =B.deviceid",$db3);
    $ThreeDayReflux = mysql_num_rows($ThreeDayReflux_query);
        //seventhDayReflux 连续7天未登录的用户在第二天登陆过游戏
    $seventhDayReflux_query = mysql_query("select DISTINCT A.deviceid from (select DISTINCT A.deviceid from faithwar A left join (select 

DISTINCT deviceid from  faithwar_all  where date between date_sub('$everylogdate[date]',interval 7 day) and 

date_sub('$everylogdate[date]',interval 1 day))B on A.deviceid =B.deviceid  where B.deviceid  is 

null) A inner join (select DISTINCT deviceid from  faithwar  where date ='$everylogdate[date]')B on 

A.deviceid =B.deviceid",$db3);
    $seventhDayReflux = mysql_num_rows($seventhDayReflux_query);
        //TwentyDayReflux 连续20天未登录的用户在第二天登陆过游戏
    $TwentyDayReflux_query = mysql_query("select DISTINCT A.deviceid from (select DISTINCT A.deviceid from faithwar A left join (select 

DISTINCT deviceid from  faithwar  where date between date_sub('$everylogdate[date]',interval 20 day) and 

date_sub('$everylogdate[date]',interval 1 day))B on A.deviceid =B.deviceid  where B.deviceid  is 

null) A inner join (select DISTINCT deviceid from  faithwar  where date ='$everylogdate[date]')B on 

A.deviceid =B.deviceid",$db3);
    $TwentyDayReflux = mysql_num_rows($TwentyDayReflux_query);

     //iap1
    $iap1_query = mysql_query(" SELECT count(1) FROM  tbiap  where  date ='$everylogdate[date]'  and money ='0.99'",$db2);
    $iap1 = mysql_fetch_array($iap1_query);
     //iap2
    $iap2_query = mysql_query("SELECT count(1) FROM  tbiap  where  date ='$everylogdate[date]' and money ='4.99' ",$db2);
    $iap2 = mysql_fetch_array($iap2_query);
     //iap3
    $iap3_query = mysql_query("SELECT count(1) FROM  tbiap  where  date ='$everylogdate[date]' and money ='9.99' ",$db2);
    $iap3 = mysql_fetch_array($iap3_query);
     //iap4
    $iap4_query = mysql_query("SELECT count(1) FROM  tbiap  where  date ='$everylogdate[date]'  and money ='19.99'",$db2);
    $iap4 = mysql_fetch_array($iap4_query);
     //iap5
    $iap5_query = mysql_query("SELECT count(1) FROM  tbiap  where  date ='$everylogdate[date]' and money ='49.99' ",$db2);
    $iap5 = mysql_fetch_array($iap5_query);
     //iap6
    $iap6_query = mysql_query("SELECT count(1) FROM  tbiap  where  date ='$everylogdate[date]' and money ='99.99' ",$db2);
    $iap6 = mysql_fetch_array($iap6_query);

     //weekPayPesonrNum 付费用户数 SELECT count( DISTINCT deviceid )  
    $weekPayPesonrNum_query = mysql_query("SELECT  count(DISTINCT deviceid) FROM faithwar WHERE money  >0  AND '$everylogdate[date]' ",$db);
    $weekPayPesonrNum = mysql_fetch_array($weekPayPesonrNum_query);

        //logARPU 登陆用户ARPU值 
   $logARPU_query = mysql_query("SELECT (
        SELECT sum( money )
        FROM faithwar
        WHERE date
        BETWEEN date_sub( '$everylogdate[date]', INTERVAL 7
        DAY )
        AND '$everylogdate[date]'
        
        ) / (
        SELECT count( DISTINCT deviceid )
        FROM faithwar
        WHERE date
        BETWEEN date_sub( '$everylogdate[date]', INTERVAL 7
        DAY )
        AND '$everylogdate[date]'
         ) ",$db);
      $logARPU = mysql_fetch_array($logARPU_query);

        //activeARPU 活跃用户ARPU值
    $activeARPU_query = mysql_query("SELECT (
        SELECT sum( money)
        FROM faithwar
        WHERE date
        BETWEEN date_sub( '$everylogdate[date]', INTERVAL 7
        DAY )
        AND '$everylogdate[date]'
        
        ) / ($weekActivePesonrNum) ",$db);
   $activeARPU = mysql_fetch_array($activeARPU_query);


       //payARPU 付费用户ARPU值 
    $payARPU_query = mysql_query("SELECT (
        SELECT sum( money)
        FROM faithwar
        WHERE date
        BETWEEN date_sub( '$everylogdate[date]', INTERVAL 7
        DAY )
        AND '$everylogdate[date]'
        
        ) / (
        '$weekPayPesonrNum[0]' )",$db);
    $payARPU = mysql_fetch_array($payARPU_query); 

        //rechargeNum 充值账户数量 历史总合
    $rechargeNum_query = mysql_query("SELECT count(DISTINCT deviceid)
        FROM faithwar
        WHERE money >0",$db3);
    $rechargeNum = mysql_fetch_array($rechargeNum_query); 
        //activerechargeNum 活跃充值账户数量 最近20天登陆过的充值账户
    $activerechargeNum_query = mysql_query("SELECT count(DISTINCT deviceid)
        FROM faithwar
        WHERE date
        BETWEEN date_sub( '$everylogdate[date]', INTERVAL 20
        DAY )
        AND '$everylogdate[date]' AND money >0",$db3);
    $activerechargeNum = mysql_fetch_array($activerechargeNum_query); 

        //TcRechargeNum 充值水晶数量
    $TcRechargeNum_query = mysql_query("SELECT sum(TcRechargeNum)
        FROM faithwar
        WHERE date = '$everylogdate[date]' ",$db);
    $TcRechargeNum = mysql_fetch_array($TcRechargeNum_query); 
        //TcUsedNum 消费水晶数量
    $TcUsedNum_query = mysql_query("SELECT sum(TcUsedNum)
        FROM faithwar
        WHERE date = '$everylogdate[date]' ",$db);
    $TcUsedNum = mysql_fetch_array($TcUsedNum_query); 
        //TcInventoryNum 用户库存水晶数量
    $TcInventoryNum_query = mysql_query("SELECT sum(TcInventoryNum)  FROM faithwar WHERE date = '$everylogdate[date]'",$db);
    $TcInventoryNum = mysql_fetch_array($TcInventoryNum_query); 

        //NewRechargeNum 新增充值用户数量
    $NewRechargeNum_query = mysql_query("select A.deviceid  from (SELECT  DISTINCT deviceid FROM `faithwar_query_temp` WHERE action =2  and 

        date 

        = DATE_SUB( 

        '$everylogdate[date]', INTERVAL 0
        DAY ) )A left join (SELECT  DISTINCT deviceid FROM `faithwar_all` WHERE 

        action =2  and date
        BETWEEN DATE_SUB( '$everylogdate[date]', INTERVAL 360
        DAY )
        AND DATE_SUB( '$everylogdate[date]', INTERVAL 1
        DAY )  )B on A.deviceid =B.deviceid  where B.deviceid  is null",$db);
    $NewRechargeNum = mysql_num_rows($NewRechargeNum_query); 


  /*
  `playerLevel` text COMMENT '当前用户等级分布(等级:人数,百分比)',
  `NewPlayerLevel` varchar(16) DEFAULT '0' COMMENT '新增玩家当前等级分布',
  `playerRoleLevel` varchar(16) DEFAULT '0' COMMENT '每个等级角色分布数量',
  `lossPlayerLevel` varchar(16) DEFAULT '0' COMMENT '流失用户等级分布',
  `activePlayer5Level` varchar(16) DEFAULT '0' COMMENT '活跃用户等级分布',
  */

    // $date1[] = 
   /* $date1_query = mysql_query("SELECT concat( (
        (
        SELECT count( DISTINCT deviceid )
        FROM faithwar a
        WHERE id = (
        SELECT max( id )
        FROM faithwar
        WHERE `deviceid` = a.`deviceid`
        AND DATE_SUB( '$everylogdate[date]', INTERVAL 7
        DAY ) <= date( date )
        AND level =1
         )
        AND DATE_SUB( '$everylogdate[date]', INTERVAL 7
        DAY ) <= date( a.date )
        AND a.level =1
        AND a.Jailbreak = '0' ) / (
        SELECT count( DISTINCT deviceid )
        FROM faithwar a
        WHERE id = (
        SELECT max( id )
        FROM faithwar
        WHERE `deviceid` = a.`deviceid`
        AND DATE_SUB( '$everylogdate[date]', INTERVAL 7
        DAY ) <= date( date )
         )
        AND DATE_SUB( '$everylogdate[date]', INTERVAL 7
        DAY ) <= date( a.date )
        AND a.Jailbreak = '0' )
        ) *100, '%')
        "); 
    $date1_a = mysql_fetch_array($date1_query); */
    $date1_a = 0;
    $date1 = $date1_a[0];
    $p1date1Count_query = mysql_query("SELECT count( DISTINCT deviceid )
        FROM faithwar
        WHERE date = '$everylogdate[date]'
        AND level = 1 
        ",$db3);
    $p1date1Count_a = mysql_fetch_array($p1date1Count_query);
    $p1date1Count = $p1date1Count_a[0];
   /* $date2_query = mysql_query("SELECT concat( (
        (
        SELECT count( DISTINCT deviceid )
        FROM faithwar a
        WHERE id = (
        SELECT max( id )
        FROM faithwar
        WHERE `deviceid` = a.`deviceid`
        AND DATE_SUB( '$everylogdate[date]', INTERVAL 7
        DAY ) <= date( date )
        AND level =2
         )
        AND DATE_SUB( '$everylogdate[date]', INTERVAL 7
        DAY ) <= date( a.date )
        AND a.level =2
        AND a.Jailbreak = '0' ) / (
        SELECT count( DISTINCT deviceid )
        FROM faithwar a
        WHERE id = (
        SELECT max( id )
        FROM faithwar
        WHERE `deviceid` = a.`deviceid`
        AND DATE_SUB( '$everylogdate[date]', INTERVAL 7
        DAY ) <= date( date )
         )
        AND DATE_SUB( '$everylogdate[date]', INTERVAL 7
        DAY ) <= date( a.date )
        AND a.Jailbreak = '0' )
        ) *100, '%')
        ");
    $date2_a = mysql_fetch_array($date2_query);*/
    $date2_a = 0;
    $date2 = $date2_a[0];
    $p1date2Count_query = mysql_query("SELECT count( DISTINCT deviceid )
        FROM faithwar
        WHERE date = '$everylogdate[date]'
        AND level = 2 ",$db3);
    $p1date2Count_a = mysql_fetch_array($p1date2Count_query);
    $p1date2Count = $p1date2Count_a[0];
   /* $date3_query = mysql_query("SELECT concat( (
        (
        SELECT count( DISTINCT deviceid )
        FROM faithwar a
        WHERE id = (
        SELECT max( id )
        FROM faithwar
        WHERE `deviceid` = a.`deviceid`
        AND DATE_SUB( '$everylogdate[date]', INTERVAL 7
        DAY ) <= date( date )
        AND level =3
         )
        AND DATE_SUB( '$everylogdate[date]', INTERVAL 7
        DAY ) <= date( a.date )
        AND a.level =3
        AND a.Jailbreak = '0' ) / (
        SELECT count( DISTINCT deviceid )
        FROM faithwar a
        WHERE id = (
        SELECT max( id )
        FROM faithwar
        WHERE `deviceid` = a.`deviceid`
        AND DATE_SUB( '$everylogdate[date]', INTERVAL 7
        DAY ) <= date( date )
         )
        AND DATE_SUB( '$everylogdate[date]', INTERVAL 7
        DAY ) <= date( a.date )
        AND a.Jailbreak = '0' )
        ) *100, '%')
        ");
    $date3_a = mysql_fetch_array($date3_query);*/
    $date3_a = 0;
    $date3 = $date3_a[0];
    $p1date3Count_query = mysql_query("SELECT count( DISTINCT deviceid )
        FROM faithwar
        WHERE date = '$everylogdate[date]'
        AND level = 3 ",$db3);
    $p1date3Count_a = mysql_fetch_array($p1date3Count_query);
    $p1date3Count = $p1date3Count_a[0];
    /*$date4_query = mysql_query("SELECT concat( (
        (
        SELECT count( DISTINCT deviceid )
        FROM faithwar a
        WHERE id = (
        SELECT max( id )
        FROM faithwar
        WHERE `deviceid` = a.`deviceid`
        AND DATE_SUB( '$everylogdate[date]', INTERVAL 7
        DAY ) <= date( date )
        AND level =4
         )
        AND DATE_SUB( '$everylogdate[date]', INTERVAL 7
        DAY ) <= date( a.date )
        AND a.level =4
        AND a.Jailbreak = '0' ) / (
        SELECT count( DISTINCT deviceid )
        FROM faithwar a
        WHERE id = (
        SELECT max( id )
        FROM faithwar
        WHERE `deviceid` = a.`deviceid`
        AND DATE_SUB( '$everylogdate[date]', INTERVAL 7
        DAY ) <= date( date )
         )
        AND DATE_SUB( '$everylogdate[date]', INTERVAL 7
        DAY ) <= date( a.date )
        AND a.Jailbreak = '0' )
        ) *100, '%')
        ");
    $date4_a = mysql_fetch_array($date4_query);*/
    $date4_a = 0;
    $date4 = $date4_a[0];
    $p1date4Count_query = mysql_query("SELECT count( DISTINCT deviceid )
        FROM faithwar
        WHERE date = '$everylogdate[date]'
        AND level = 4 ",$db3);
    $p1date4Count_a = mysql_fetch_array($p1date4Count_query);
    $p1date4Count = $p1date4Count_a[0];
    /*$date5_query = mysql_query("SELECT concat( (
        (
        SELECT count( DISTINCT deviceid )
        FROM faithwar a
        WHERE id = (
        SELECT max( id )
        FROM faithwar
        WHERE `deviceid` = a.`deviceid`
        AND DATE_SUB( '$everylogdate[date]', INTERVAL 7
        DAY ) <= date( date )
        AND level =5
         )
        AND DATE_SUB( '$everylogdate[date]', INTERVAL 7
        DAY ) <= date( a.date )
        AND a.level =5
        AND a.Jailbreak = '0' ) / (
        SELECT count( DISTINCT deviceid )
        FROM faithwar a
        WHERE id = (
        SELECT max( id )
        FROM faithwar
        WHERE `deviceid` = a.`deviceid`
        AND DATE_SUB( '$everylogdate[date]', INTERVAL 7
        DAY ) <= date( date )
         )
        AND DATE_SUB( '$everylogdate[date]', INTERVAL 7
        DAY ) <= date( a.date )
        AND a.Jailbreak = '0' )
        ) *100, '%')
        ");
    $date5_a = mysql_fetch_array($date5_query);*/
    $date5_a = 0;
    $date5 = $date5_a[0];
    $p1date5Count_query = mysql_query("SELECT count( DISTINCT deviceid )
        FROM faithwar
        WHERE date = '$everylogdate[date]'
        AND level = 5 ",$db3);
    $p1date5Count_a = mysql_fetch_array($p1date5Count_query);
    $p1date5Count = $p1date5Count_a[0];
    /*$date6_query = mysql_query("SELECT concat( (
        (
        SELECT count( DISTINCT deviceid )
        FROM faithwar a
        WHERE id = (
        SELECT max( id )
        FROM faithwar
        WHERE `deviceid` = a.`deviceid`
        AND DATE_SUB( '$everylogdate[date]', INTERVAL 7
        DAY ) <= date( date )
        AND level =6
         )
        AND DATE_SUB( '$everylogdate[date]', INTERVAL 7
        DAY ) <= date( a.date )
        AND a.level =6
        AND a.Jailbreak = '0' ) / (
        SELECT count( DISTINCT deviceid )
        FROM faithwar a
        WHERE id = (
        SELECT max( id )
        FROM faithwar
        WHERE `deviceid` = a.`deviceid`
        AND DATE_SUB( '$everylogdate[date]', INTERVAL 7
        DAY ) <= date( date )
         )
        AND DATE_SUB( '$everylogdate[date]', INTERVAL 7
        DAY ) <= date( a.date )
        AND a.Jailbreak = '0' )
        ) *100, '%')
        ");
    $date6_a = mysql_fetch_array($date6_query);*/
    $date6_a = 0;
    $date6 = $date6_a[0];
    $p1date6Count_query = mysql_query("SELECT count( DISTINCT deviceid )
        FROM faithwar
        WHERE date = '$everylogdate[date]'
        AND level = 6 ",$db3);
    $p1date6Count_a = mysql_fetch_array($p1date6Count_query);
    $p1date6Count = $p1date6Count_a[0];
   /* $date7_query = mysql_query("SELECT concat( (
        (
        SELECT count( DISTINCT deviceid )
        FROM faithwar a
        WHERE id = (
        SELECT max( id )
        FROM faithwar
        WHERE `deviceid` = a.`deviceid`
        AND DATE_SUB( '$everylogdate[date]', INTERVAL 7
        DAY ) <= date( date )
        AND level =7
         )
        AND DATE_SUB( '$everylogdate[date]', INTERVAL 7
        DAY ) <= date( a.date )
        AND a.level =7
        AND a.Jailbreak = '0' ) / (
        SELECT count( DISTINCT deviceid )
        FROM faithwar a
        WHERE id = (
        SELECT max( id )
        FROM faithwar
        WHERE `deviceid` = a.`deviceid`
        AND DATE_SUB( '$everylogdate[date]', INTERVAL 7
        DAY ) <= date( date )
         )
        AND DATE_SUB( '$everylogdate[date]', INTERVAL 7
        DAY ) <= date( a.date )
        AND a.Jailbreak = '0' )
        ) *100, '%')
        ");
    $date7_a = mysql_fetch_array($date7_query);*/
    $date7_a = 0;
    $date7 = $date7_a[0];
    $p1date7Count_query = mysql_query("SELECT count( DISTINCT deviceid )
        FROM faithwar
        WHERE date = '$everylogdate[date]'
        AND level = 7 ",$db3);
    $p1date7Count_a = mysql_fetch_array($p1date7Count_query);
    $p1date7Count = $p1date7Count_a[0];
    /*$date8_query = mysql_query("SELECT concat( (
        (
        SELECT count( DISTINCT deviceid )
        FROM faithwar a
        WHERE id = (
        SELECT max( id )
        FROM faithwar
        WHERE `deviceid` = a.`deviceid`
        AND DATE_SUB( '$everylogdate[date]', INTERVAL 7
        DAY ) <= date( date )
        AND level =8
         )
        AND DATE_SUB( '$everylogdate[date]', INTERVAL 7
        DAY ) <= date( a.date )
        AND a.level =8
        AND a.Jailbreak = '0' ) / (
        SELECT count( DISTINCT deviceid )
        FROM faithwar a
        WHERE id = (
        SELECT max( id )
        FROM faithwar
        WHERE `deviceid` = a.`deviceid`
        AND DATE_SUB( '$everylogdate[date]', INTERVAL 7
        DAY ) <= date( date )
         )
        AND DATE_SUB( '$everylogdate[date]', INTERVAL 7
        DAY ) <= date( a.date )
        AND a.Jailbreak = '0' )
        ) *100, '%')
        ");
    $date8_a = mysql_fetch_array($date8_query);*/
    $date8_a = 0;
    $date8 = $date8_a[0];
    $p1date8Count_query = mysql_query("SELECT count( DISTINCT deviceid )
        FROM faithwar
        WHERE date = '$everylogdate[date]'
        AND level = 8 ",$db3);
    $p1date8Count_a = mysql_fetch_array($p1date8Count_query);
    $p1date8Count = $p1date8Count_a[0];
    /*$date9_query = mysql_query("SELECT concat( (
        (
        SELECT count( DISTINCT deviceid )
        FROM faithwar a
        WHERE id = (
        SELECT max( id )
        FROM faithwar
        WHERE `deviceid` = a.`deviceid`
        AND DATE_SUB( '$everylogdate[date]', INTERVAL 7
        DAY ) <= date( date )
        AND level =9
         )
        AND DATE_SUB( '$everylogdate[date]', INTERVAL 7
        DAY ) <= date( a.date )
        AND a.level =9
        AND a.Jailbreak = '0' ) / (
        SELECT count( DISTINCT deviceid )
        FROM faithwar a
        WHERE id = (
        SELECT max( id )
        FROM faithwar
        WHERE `deviceid` = a.`deviceid`
        AND DATE_SUB( '$everylogdate[date]', INTERVAL 7
        DAY ) <= date( date )
         )
        AND DATE_SUB( '$everylogdate[date]', INTERVAL 7
        DAY ) <= date( a.date )
        AND a.Jailbreak = '0' )
        ) *100, '%')
        ");
    $date9_a = mysql_fetch_array($date9_query);*/
    $date9_a = 0;
    $date9 = $date9_a[0];
    $p1date9Count_query = mysql_query("SELECT count( DISTINCT deviceid )
        FROM faithwar
        WHERE date = '$everylogdate[date]'
        AND level = 9 ",$db3);
    $p1date9Count_a = mysql_fetch_array($p1date9Count_query);
    $p1date9Count = $p1date9Count_a[0];
    /*$date10_query = mysql_query("SELECT concat( (
        (
        SELECT count( DISTINCT deviceid )
        FROM faithwar a
        WHERE id = (
        SELECT max( id )
        FROM faithwar
        WHERE `deviceid` = a.`deviceid`
        AND DATE_SUB( '$everylogdate[date]', INTERVAL 7
        DAY ) <= date( date )
        AND level =10
         )
        AND DATE_SUB( '$everylogdate[date]', INTERVAL 7
        DAY ) <= date( a.date )
        AND a.level =10
        AND a.Jailbreak = '0' ) / (
        SELECT count( DISTINCT deviceid )
        FROM faithwar a
        WHERE id = (
        SELECT max( id )
        FROM faithwar
        WHERE `deviceid` = a.`deviceid`
        AND DATE_SUB( '$everylogdate[date]', INTERVAL 7
        DAY ) <= date( date )
         )
        AND DATE_SUB( '$everylogdate[date]', INTERVAL 7
        DAY ) <= date( a.date )
        AND a.Jailbreak = '0' )
        ) *100, '%')
        ");
    $date10_a = mysql_fetch_array($date10_query);*/
    $date10_a = 0;
    $date10 = $date10_a[0];
    $p1date10Count_query = mysql_query("SELECT count( DISTINCT deviceid )
        FROM faithwar
        WHERE date = '$everylogdate[date]'
        AND level = 10 ",$db3);
    $p1date10Count_a = mysql_fetch_array($p1date10Count_query);
    $p1date10Count = $p1date10Count_a[0];
    /*$date11_query = mysql_query("SELECT concat( (
        (
        SELECT count( DISTINCT deviceid )
        FROM faithwar a
        WHERE id = (
        SELECT max( id )
        FROM faithwar
        WHERE `deviceid` = a.`deviceid`
        AND DATE_SUB( '$everylogdate[date]', INTERVAL 7
        DAY ) <= date( date )
        AND level between 11 and 15
         )
        AND DATE_SUB( '$everylogdate[date]', INTERVAL 7
        DAY ) <= date( a.date )
        AND a.level between 11 and 15
        AND a.Jailbreak = '0' ) / (
        SELECT count( DISTINCT deviceid )
        FROM faithwar a
        WHERE id = (
        SELECT max( id )
        FROM faithwar
        WHERE `deviceid` = a.`deviceid`
        AND DATE_SUB( '$everylogdate[date]', INTERVAL 7
        DAY ) <= date( date )
         )
        AND DATE_SUB( '$everylogdate[date]', INTERVAL 7
        DAY ) <= date( a.date )
        AND a.Jailbreak = '0' )
        ) *100, '%')
        ");
    $date11_a = mysql_fetch_array($date11_query);*/
    $date11_a = 0;
    $date11 = $date11_a[0];
    $p1date11Count_query = mysql_query("SELECT count( DISTINCT deviceid )
        FROM faithwar
        WHERE date = '$everylogdate[date]'
        AND level between 11 and 15 ",$db3);
    $p1date11Count_a = mysql_fetch_array($p1date11Count_query);
    $p1date11Count = $p1date11Count_a[0];
    /*$date12_query = mysql_query("SELECT concat( (
        (
        SELECT count( DISTINCT deviceid )
        FROM faithwar a
        WHERE id = (
        SELECT max( id )
        FROM faithwar
        WHERE `deviceid` = a.`deviceid`
        AND DATE_SUB( '$everylogdate[date]', INTERVAL 7
        DAY ) <= date( date )
        AND level between 16 and 20
         )
        AND DATE_SUB( '$everylogdate[date]', INTERVAL 7
        DAY ) <= date( a.date )
        AND a.level between 16 and 20
        AND a.Jailbreak = '0' ) / (
        SELECT count( DISTINCT deviceid )
        FROM faithwar a
        WHERE id = (
        SELECT max( id )
        FROM faithwar
        WHERE `deviceid` = a.`deviceid`
        AND DATE_SUB( '$everylogdate[date]', INTERVAL 7
        DAY ) <= date( date )
         )
        AND DATE_SUB( '$everylogdate[date]', INTERVAL 7
        DAY ) <= date( a.date )
        AND a.Jailbreak = '0' )
        ) *100, '%'
        )");
    $date12_a = mysql_fetch_array($date12_query);*/
    $date12_a =0;
    $date12 = $date12_a[0];
    $p1date12Count_query = mysql_query("SELECT count( DISTINCT deviceid )
        FROM faithwar
        WHERE date = '$everylogdate[date]'
        AND level between 16 and 20 ",$db3);
    $p1date12Count_a = mysql_fetch_array($p1date12Count_query);
    $p1date12Count = $p1date12Count_a[0];
    /*$date13_query = mysql_query("SELECT concat( (
        (
        SELECT count( DISTINCT deviceid )
        FROM faithwar a
        WHERE id = (
        SELECT max( id )
        FROM faithwar
        WHERE `deviceid` = a.`deviceid`
        AND DATE_SUB( '$everylogdate[date]', INTERVAL 7
        DAY ) <= date( date )
        AND level between 21 and 25
         )
        AND DATE_SUB( '$everylogdate[date]', INTERVAL 7
        DAY ) <= date( a.date )
        AND a.level between 21 and 25
        AND a.Jailbreak = '0' ) / (
        SELECT count( DISTINCT deviceid )
        FROM faithwar a
        WHERE id = (
        SELECT max( id )
        FROM faithwar
        WHERE `deviceid` = a.`deviceid`
        AND DATE_SUB( '$everylogdate[date]', INTERVAL 7
        DAY ) <= date( date )
         )
        AND DATE_SUB( '$everylogdate[date]', INTERVAL 7
        DAY ) <= date( a.date )
        AND a.Jailbreak = '0' )
        ) *100, '%')");
    $date13_a = mysql_fetch_array($date13_query);*/
    $date13_a = 0;
    $date13 = $date13_a[0];
    $p1date13Count_query = mysql_query("SELECT count( DISTINCT deviceid )
        FROM faithwar
        WHERE date =  '$everylogdate[date]'
        AND level between 21 and 25 ",$db3);
    $p1date13Count_a = mysql_fetch_array($p1date13Count_query);
    $p1date13Count = $p1date13Count_a[0];
    /*$date14_query = mysql_query("SELECT concat( (
        (
        SELECT count( DISTINCT deviceid )
        FROM faithwar a
        WHERE id = (
        SELECT max( id )
        FROM faithwar
        WHERE `deviceid` = a.`deviceid`
        AND DATE_SUB( '$everylogdate[date]', INTERVAL 7
        DAY ) <= date( date )
        AND level between 26 and 30
         )
        AND DATE_SUB( '$everylogdate[date]', INTERVAL 7
        DAY ) <= date( a.date )
        AND a.level between 26 and 30
        AND a.Jailbreak = '0' ) / (
        SELECT count( DISTINCT deviceid )
        FROM faithwar a
        WHERE id = (
        SELECT max( id )
        FROM faithwar
        WHERE `deviceid` = a.`deviceid`
        AND DATE_SUB( '$everylogdate[date]', INTERVAL 7
        DAY ) <= date( date )
         )
        AND DATE_SUB( '$everylogdate[date]', INTERVAL 7
        DAY ) <= date( a.date )
        AND a.Jailbreak = '0' )
        ) *100, '%')");
    $date14_a = mysql_fetch_array($date14_query);*/
     $date14_a = 0;
    $date14 = $date14_a[0];
    $p1date14Count_query = mysql_query("SELECT count( DISTINCT deviceid )
        FROM faithwar
        WHERE date = '$everylogdate[date]'
        AND level between 26 and 30 ",$db3);
    $p1date14Count_a = mysql_fetch_array($p1date14Count_query);
    $p1date14Count = $p1date14Count_a[0];
    /*$date15_query = mysql_query("SELECT concat( (
        (
        SELECT count( DISTINCT deviceid )
        FROM faithwar a
        WHERE id = (
        SELECT max( id )
        FROM faithwar
        WHERE `deviceid` = a.`deviceid`
        AND DATE_SUB( '$everylogdate[date]', INTERVAL 7
        DAY ) <= date( date )
        AND level between 31 and 40
         )
        AND DATE_SUB( '$everylogdate[date]', INTERVAL 7
        DAY ) <= date( a.date )
        AND a.level between 31 and 40
        AND a.Jailbreak = '0' ) / (
        SELECT count( DISTINCT deviceid )
        FROM faithwar a
        WHERE id = (
        SELECT max( id )
        FROM faithwar
        WHERE `deviceid` = a.`deviceid`
        AND DATE_SUB( '$everylogdate[date]', INTERVAL 7
        DAY ) <= date( date )
         )
        AND DATE_SUB( '$everylogdate[date]', INTERVAL 7
        DAY ) <= date( a.date )
        AND a.Jailbreak = '0' )
        ) *100, '%')");
    $date15_a = mysql_fetch_array($date15_query);*/
    $date15_a = 0;
    $date15 = $date15_a[0];
    $p1date15Count_query = mysql_query("SELECT count( DISTINCT deviceid )
        FROM faithwar
        WHERE date = '$everylogdate[date]'
        AND level between 31 and 40 ",$db3);
    $p1date15Count_a = mysql_fetch_array($p1date15Count_query);
    $p1date15Count = $p1date15Count_a[0];
    /*$date16_query = mysql_query("SELECT concat( (
        (
        SELECT count( DISTINCT deviceid )
        FROM faithwar a
        WHERE id = (
        SELECT max( id )
        FROM faithwar
        WHERE `deviceid` = a.`deviceid`
        AND DATE_SUB( '$everylogdate[date]', INTERVAL 7
        DAY ) <= date( date )
        AND level between 41 and 50
         )
        AND DATE_SUB( '$everylogdate[date]', INTERVAL 7
        DAY ) <= date( a.date )
        AND a.level between 41 and 50
        AND a.Jailbreak = '0' ) / (
        SELECT count( DISTINCT deviceid )
        FROM faithwar a
        WHERE id = (
        SELECT max( id )
        FROM faithwar
        WHERE `deviceid` = a.`deviceid`
        AND DATE_SUB( '$everylogdate[date]', INTERVAL 7
        DAY ) <= date( date )
         )
        AND DATE_SUB( '$everylogdate[date]', INTERVAL 7
        DAY ) <= date( a.date )
        AND a.Jailbreak = '0' )
        ) *100, '%')");
    $date16_a = mysql_fetch_array($date16_query);*/
     $date16_a =0;
    $date16 = $date16_a[0];
    $p1date16Count_query = mysql_query("SELECT count( DISTINCT deviceid )
        FROM faithwar
        WHERE date = '$everylogdate[date]'
        AND level between 41 and 50 ",$db3);
    $p1date16Count_a = mysql_fetch_array($p1date16Count_query);
    $p1date16Count = $p1date16Count_a[0];
    /*$date17_query = mysql_query("SELECT concat( (
        (
        SELECT count( DISTINCT deviceid )
        FROM faithwar a
        WHERE id = (
        SELECT max( id )
        FROM faithwar
        WHERE `deviceid` = a.`deviceid`
        AND DATE_SUB( '$everylogdate[date]', INTERVAL 7
        DAY ) <= date( date )
        AND level between 51 and 60
         )
        AND DATE_SUB( '$everylogdate[date]', INTERVAL 7
        DAY ) <= date( a.date )
        AND a.level between 51 and 60
        AND a.Jailbreak = '0' ) / (
        SELECT count( DISTINCT deviceid )
        FROM faithwar a
        WHERE id = (
        SELECT max( id )
        FROM faithwar
        WHERE `deviceid` = a.`deviceid`
        AND DATE_SUB( '$everylogdate[date]', INTERVAL 7
        DAY ) <= date( date )
         )
        AND DATE_SUB( '$everylogdate[date]', INTERVAL 7
        DAY ) <= date( a.date )
        AND a.Jailbreak = '0' )
        ) *100, '%')");
    $date17_a = mysql_fetch_array($date17_query);*/
    $date17_a = 0;
    $date17 = $date17_a[0];
    $p1date17Count_query = mysql_query("SELECT count( DISTINCT deviceid )
        FROM faithwar
        WHERE date = '$everylogdate[date]'
        AND level between 51 and 60 ",$db3);
    $p1date17Count_a = mysql_fetch_array($p1date17Count_query);
    $p1date17Count = $p1date17Count_a[0];
    /*$date18_query = mysql_query("SELECT concat( (
        (
        SELECT count( DISTINCT deviceid )
        FROM faithwar a
        WHERE id = (
        SELECT max( id )
        FROM faithwar
        WHERE `deviceid` = a.`deviceid`
        AND DATE_SUB( '$everylogdate[date]', INTERVAL 7
        DAY ) <= date( date )
        AND level between 61 and 70
         )
        AND DATE_SUB( '$everylogdate[date]', INTERVAL 7
        DAY ) <= date( a.date )
        AND a.level between 61 and 70
        AND a.Jailbreak = '0' ) / (
        SELECT count( DISTINCT deviceid )
        FROM faithwar a
        WHERE id = (
        SELECT max( id )
        FROM faithwar
        WHERE `deviceid` = a.`deviceid`
        AND DATE_SUB( '$everylogdate[date]', INTERVAL 7
        DAY ) <= date( date )
         )
        AND DATE_SUB( '$everylogdate[date]', INTERVAL 7
        DAY ) <= date( a.date )
        AND a.Jailbreak = '0' )
        ) *100, '%')");
    $date18_a = mysql_fetch_array($date18_query);*/
    $date18_a =0;
    $date18 = $date18_a[0];
    $p1date18Count_query = mysql_query("SELECT count( DISTINCT deviceid )
        FROM faithwar
        WHERE date = '$everylogdate[date]'
        AND level between 61 and 70 ",$db3);
    $p1date18Count_a = mysql_fetch_array($p1date18Count_query);
    $p1date18Count = $p1date18Count_a[0];
    /*$date19_query = mysql_query("SELECT concat( (
        (
        SELECT count( DISTINCT deviceid )
        FROM faithwar a
        WHERE id = (
        SELECT max( id )
        FROM faithwar
        WHERE `deviceid` = a.`deviceid`
        AND DATE_SUB( '$everylogdate[date]', INTERVAL 7
        DAY ) <= date( date )
        AND level between 71 and 80
         )
        AND DATE_SUB( '$everylogdate[date]', INTERVAL 7
        DAY ) <= date( a.date )
        AND a.level between 71 and 80
        AND a.Jailbreak = '0' ) / (
        SELECT count( DISTINCT deviceid )
        FROM faithwar a
        WHERE id = (
        SELECT max( id )
        FROM faithwar
        WHERE `deviceid` = a.`deviceid`
        AND DATE_SUB( '$everylogdate[date]', INTERVAL 7
        DAY ) <= date( date )
         )
        AND DATE_SUB( '$everylogdate[date]', INTERVAL 7
        DAY ) <= date( a.date )
        AND a.Jailbreak = '0' )
        ) *100, '%')");
    $date19_a = mysql_fetch_array($date19_query);*/
    $date19_a = 0;
    $date19 = $date19_a[0];
    $p1date19Count_query = mysql_query("SELECT count( DISTINCT deviceid )
        FROM faithwar
        WHERE date = '$everylogdate[date]'
        AND level between 71 and 80 ",$db3);
    $p1date19Count_a = mysql_fetch_array($p1date19Count_query);
    $p1date19Count = $p1date19Count_a[0];
    /*$date20_query = mysql_query("SELECT concat( (
        (
        SELECT count( DISTINCT deviceid )
        FROM faithwar a
        WHERE id = (
        SELECT max( id )
        FROM faithwar
        WHERE `deviceid` = a.`deviceid`
        AND DATE_SUB( '$everylogdate[date]', INTERVAL 7
        DAY ) <= date( date )
        AND level between 81 and 90
         )
        AND DATE_SUB( '$everylogdate[date]', INTERVAL 7
        DAY ) <= date( a.date )
        AND a.level between 81 and 90
        AND a.Jailbreak = '0' ) / (
        SELECT count( DISTINCT deviceid )
        FROM faithwar a
        WHERE id = (
        SELECT max( id )
        FROM faithwar
        WHERE `deviceid` = a.`deviceid`
        AND DATE_SUB( '$everylogdate[date]', INTERVAL 7
        DAY ) <= date( date )
         )
        AND DATE_SUB( '$everylogdate[date]', INTERVAL 7
        DAY ) <= date( a.date )
        AND a.Jailbreak = '0' )
        ) *100, '%')");
    $date20_a = mysql_fetch_array($date20_query);*/
    $date20_a = 0;
    $date20 = $date20_a[0];
    $p1date20Count_query = mysql_query("SELECT count( DISTINCT deviceid )
        FROM faithwar
        WHERE date =  '$everylogdate[date]'
        AND level between 81 and 90 ",$db3);
    $p1date20Count_a = mysql_fetch_array($p1date20Count_query);
    $p1date20Count = $p1date20Count_a[0];
    /*$date21_query = mysql_query("SELECT concat( (
        (
        SELECT count( DISTINCT deviceid )
        FROM faithwar a
        WHERE id = (
        SELECT max( id )
        FROM faithwar
        WHERE `deviceid` = a.`deviceid`
        AND DATE_SUB( '$everylogdate[date]', INTERVAL 7
        DAY ) <= date( date )
        AND level between 91 and 100
         )
        AND DATE_SUB( '$everylogdate[date]', INTERVAL 7
        DAY ) <= date( a.date )
        AND a.level between 91 and 100
        AND a.Jailbreak = '0' ) / (
        SELECT count( DISTINCT deviceid )
        FROM faithwar a
        WHERE id = (
        SELECT max( id )
        FROM faithwar
        WHERE `deviceid` = a.`deviceid`
        AND DATE_SUB( '$everylogdate[date]', INTERVAL 7
        DAY ) <= date( date )
         )
        AND DATE_SUB( '$everylogdate[date]', INTERVAL 7
        DAY ) <= date( a.date )
        AND a.Jailbreak = '0' )
        ) *100, '%')");
    $date21_a = mysql_fetch_array($date21_query);*/
    $date21_a = 0;
    $date21 = $date21_a[0];
    $p1date21Count_query = mysql_query("SELECT count( DISTINCT deviceid )
        FROM faithwar
        WHERE date = '$everylogdate[date]'
        AND level between 91 and 100 ",$db3);
    $p1date21Count_a = mysql_fetch_array($p1date21Count_query);
    $p1date21Count = $p1date21Count_a[0];
    // p1等级分布 (1,2,....)
    $date = array('1' => array($p1date1Count, $date1), array($p1date2Count, $date2), array($p1date3Count, $date3), array($p1date4Count, $date4), array($p1date5Count, $date5), array($p1date6Count, $date6), array($p1date7Count, $date7), array($p1date8Count, $date8), array($p1date9Count, $date9), array($p1date10Count, $date10), array($p1date11Count, $date11), array($p1date12Count, $date12), array($p1date13Count, $date13), array($p1date14Count, $date14), array($p1date15Count, $date15), array($p1date16Count, $date16), array($p1date17Count, $date17), array($p1date18Count, $date18), array($p1date19Count, $date19), array($p1date20Count, $date20), array($p1date21Count, $date21));
   
    $level = array(json_encode($date));//等级分布 

    //sevenTotal 七日总用户
    $sevenTotal_query = mysql_query("SELECT DISTINCT deviceid
        FROM faithwar
        WHERE date
        BETWEEN DATE_SUB( '$everylogdate[date]', INTERVAL 14
        DAY )
        AND  DATE_SUB( '$everylogdate[date]', INTERVAL 7
        DAY )",$db3);
    //$sevenTotal = mysql_fetch_array($sevenTotal_query); //list
    $sevenTotalRow = mysql_num_rows($sevenTotal_query);//总行
    
        //firstLoss 第一日 差集
    $firstLoss_query = mysql_query("SELECT count(DISTINCT a.deviceid)
        FROM (
        SELECT DISTINCT a.deviceid
        FROM faithwar  a
        WHERE  a.date BETWEEN DATE_SUB( '$everylogdate[date]', INTERVAL 14 DAY ) AND  DATE_SUB( '$everylogdate[date]', INTERVAL 8 DAY )
        )a
        LEFT JOIN (

        SELECT DISTINCT deviceid
        FROM faithwar 
        WHERE  date = DATE_SUB( '$everylogdate[date]', INTERVAL 8 DAY )
        )b ON a.deviceid = b.deviceid
        WHERE b.deviceid IS  NULL",$db3);
    $firstLoss = mysql_fetch_array($firstLoss_query);
    //firstWastageRate 七日流失率 第一天
    $firstWastageRate_query = mysql_query("SELECT concat(round( '$firstLoss[0]'/ '$sevenTotalRow' *100,2), '%' )",$db3);
    $firstWastageRate = mysql_fetch_array($firstWastageRate_query);
        //secondLoss 第二日 差集
    $secondLoss_query = mysql_query("SELECT count(DISTINCT a.deviceid)
        FROM (
        SELECT DISTINCT a.deviceid
        FROM faithwar  a
        WHERE  a.date BETWEEN DATE_SUB( '$everylogdate[date]', INTERVAL 14 DAY ) AND  DATE_SUB( '$everylogdate[date]', INTERVAL 9 DAY )
        )a
        LEFT JOIN (

        SELECT DISTINCT deviceid
        FROM faithwar 
        WHERE  date = DATE_SUB( '$everylogdate[date]', INTERVAL 8 DAY )
        )b ON a.deviceid = b.deviceid
        WHERE b.deviceid IS  NULL",$db3);
    $secondLoss = mysql_fetch_array($secondLoss_query);
    //secondWastageRate 七日流失率 第二天
    $secondWastageRate_query = mysql_query("SELECT concat(round( '$secondLoss[0]'/ '$sevenTotalRow' *100,2), '%' )",$db3);
    $secondWastageRate = mysql_fetch_array($secondWastageRate_query);
        //thirdLoss 第三日 差集
    $thirdLoss_query = mysql_query("SELECT count(DISTINCT a.deviceid)
        FROM (
        SELECT DISTINCT a.deviceid
        FROM faithwar  a
        WHERE  a.date BETWEEN DATE_SUB( '$everylogdate[date]', INTERVAL 14 DAY ) AND  DATE_SUB( '$everylogdate[date]', INTERVAL 10 DAY )
        )a
        LEFT JOIN (

        SELECT DISTINCT deviceid
        FROM faithwar 
        WHERE  date = DATE_SUB( '$everylogdate[date]', INTERVAL 8 DAY )
        )b ON a.deviceid = b.deviceid
        WHERE b.deviceid IS  NULL",$db3);
    $thirdLoss = mysql_fetch_array($thirdLoss_query);
    //thirdWastageRate 七日流失率 第三天
    $thirdWastageRate_query = mysql_query("SELECT concat(round( '$thirdLoss[0]'/ '$sevenTotalRow' *100,2), '%' )",$db3);
    $thirdWastageRate = mysql_fetch_array($thirdWastageRate_query);
        //fourthLoss 第四日 差集
    $fourthLoss_query = mysql_query("SELECT count(DISTINCT a.deviceid)
        FROM (
        SELECT DISTINCT a.deviceid
        FROM faithwar  a
        WHERE  a.date BETWEEN DATE_SUB( '$everylogdate[date]', INTERVAL 14 DAY ) AND  DATE_SUB( '$everylogdate[date]', INTERVAL 11 DAY )
        )a
        LEFT JOIN (

        SELECT DISTINCT deviceid
        FROM faithwar 
        WHERE  date = DATE_SUB( '$everylogdate[date]', INTERVAL 8 DAY )
        )b ON a.deviceid = b.deviceid
        WHERE b.deviceid IS  NULL",$db3);
    $fourthLoss = mysql_fetch_array($fourthLoss_query);
    //fourthWastageRate 七日流失率 第四天
    $fourthWastageRate_query = mysql_query("SELECT concat(round( '$fourthLoss[0]'/ '$sevenTotalRow' *100,2), '%' )",$db3);
    $fourthWastageRate = mysql_fetch_array($fourthWastageRate_query);
        //fifthLoss 第五日 差集
    $fifthLoss_query = mysql_query("SELECT count(DISTINCT a.deviceid)
        FROM (
        SELECT DISTINCT a.deviceid
        FROM faithwar  a
        WHERE  a.date BETWEEN DATE_SUB( '$everylogdate[date]', INTERVAL 14 DAY ) AND  DATE_SUB( '$everylogdate[date]', INTERVAL 12 DAY )
        )a
        LEFT JOIN (

        SELECT DISTINCT deviceid
        FROM faithwar 
        WHERE  date = DATE_SUB( '$everylogdate[date]', INTERVAL 8 DAY )
        )b ON a.deviceid = b.deviceid
        WHERE b.deviceid IS  NULL",$db3);
    $fifthLoss = mysql_fetch_array($fifthLoss_query);

    //fifthWastageRate 七日流失率 第五天
    $fifthWastageRate_query = mysql_query("SELECT concat(round( '$fifthLoss[0]'/ '$sevenTotalRow' *100,2), '%' )",$db3);
    $fifthWastageRate = mysql_fetch_array($fifthWastageRate_query);
   
    //sixthLoss 第六日 差集
    $sixthLoss_query = mysql_query("SELECT count(DISTINCT a.deviceid)
        FROM (
        SELECT DISTINCT a.deviceid
        FROM faithwar  a
        WHERE  a.date BETWEEN DATE_SUB( '$everylogdate[date]', INTERVAL 14 DAY ) AND  DATE_SUB( '$everylogdate[date]', INTERVAL 13 DAY )
        )a
        LEFT JOIN (

        SELECT DISTINCT deviceid
        FROM faithwar 
        WHERE  date = DATE_SUB( '$everylogdate[date]', INTERVAL 8 DAY )
        )b ON a.deviceid = b.deviceid
        WHERE b.deviceid IS  NULL",$db3);
    $sixthLoss = mysql_fetch_array($sixthLoss_query);
    //sixthWastageRate 七日流失率 第六天
    $sixthWastageRate_query = mysql_query("SELECT concat(round( '$sixthLoss[0]'/ '$sevenTotalRow' *100,2), '%' )",$db3);
    $sixthWastageRate = mysql_fetch_array($sixthWastageRate_query);
   
    //seventhLoss 第七日 差集
    $seventhLoss_query = mysql_query("SELECT count(DISTINCT a.deviceid)
        FROM (
        SELECT DISTINCT a.deviceid
        FROM faithwar  a
        WHERE  a.date BETWEEN DATE_SUB( '$everylogdate[date]', INTERVAL 14 DAY ) AND  DATE_SUB( '$everylogdate[date]', INTERVAL 14 DAY )
        )a
        LEFT JOIN (

        SELECT DISTINCT deviceid
        FROM faithwar 
        WHERE  date = DATE_SUB( '$everylogdate[date]', INTERVAL 8 DAY )
        )b ON a.deviceid = b.deviceid
        WHERE b.deviceid IS  NULL",$db3);
    $seventhLoss = mysql_fetch_array($seventhLoss_query);

    //seventhWastageRate 七日流失率 第七天
    $seventhWastageRate_query = mysql_query("SELECT concat(round( '$seventhLoss[0]'/ '$sevenTotalRow' *100,2), '%' )",$db3);
    $seventhWastageRate = mysql_fetch_array($seventhWastageRate_query);

    //dailyLogNum 每日登陆人数
    $dailyLogNum_query = mysql_query("SELECT count(DISTINCT deviceid)  FROM  faithwar  where date ='$everylogdate[date]'",$db3);
    $dailyLogNum = mysql_fetch_array($dailyLogNum_query);

    //dailyLogTime 每日登陆人次
    $dailyLogTime_query = mysql_query("SELECT count(1)  FROM  faithwar  where date ='$everylogdate[date]' and action =1 ",$db3);
    $dailyLogTime = mysql_fetch_array($dailyLogTime_query);

    //dailyOldUserLogNum 老用户每日登陆人数
    $dailyOldUserLogNum_query = mysql_query("SELECT count(DISTINCT deviceid)  FROM  faithwar  where date ='$everylogdate[date]' and  action <>3 and firstlogindata <'$everylogdate[date]'",$db3);
    $dailyOldUserLogNum = mysql_fetch_array($dailyOldUserLogNum_query);

    //dailyOldUserLogTime 老用户每日登陆人次
    $dailyOldUserLogTime_query = mysql_query("SELECT count(1)  FROM  faithwar  where date ='$everylogdate[date]' and  action =1 and firstlogindata <'$everylogdate[date]'",$db3);
    $dailyOldUserLogTime = mysql_fetch_array($dailyOldUserLogTime_query);

    //ArmyCount 军队生产
    $ArmyCount_query = mysql_query("SELECT sum(targetCount)  FROM  faithwar  where date ='$everylogdate[date]' and action =51",$db3);
    $ArmyCount = mysql_fetch_array($ArmyCount_query);


$sql="REPLACE INTO report_nojailbreak (logdate,
          totalDayNewusers,
          dayActivePesonrNum,
          dayActivePesonrTime,
          totalDayPlayTime,
          dayPlayTime,
          totalDayTotalTime,
          dayTotalTime,
          newPayPesonrNum,
          PayPesonrNum,
          paytimes,
          WeekNewPayPesonrNum,
          weekOneLandPesonrNum,
          weekActivePesonrNum,
          weekLoyalPesonrNum,
          weekCorePesonrNum,
          weekFivePesonrNum,
          MonthLandTwicePesonrNum,
          NewFiveSeconds,
          NewTenSeconds,
          NewTwentySeconds,
          NewThirtySeconds,
          NewSixtySeconds,
          New120Seconds,
          New200Seconds,
          New300Seconds,
          New500Seconds,
          New700Seconds,
          New1000Seconds,
          New1500Seconds,
          New2000Seconds,
          FiveSeconds,
          TenSeconds,
          TwentySeconds,
          ThirtySeconds,
          SixtySeconds,
          _120Seconds,
          _200Seconds,
          _300Seconds,
          _500Seconds,
          _700Seconds,
          _1000Seconds,
          _1500Seconds,
          _2000Seconds,
          ThreeDayWastageRate,
          seventhDayWastageRate,
          TwentyDayWastageRate,
          ThreeDayReflux,
          seventhDayReflux,
          TwentyDayReflux,
          iap1,
          iap2,
          iap3,
          iap4,
          iap5,
          iap6,
          logARPU,
          activeARPU,
          payARPU,
          rechargeNum,
          activerechargeNum,
          TcRechargeNum,
          TcUsedNum,
          TcInventoryNum,
          NewRechargeNum,
          playerLevel,
          firstWastageRate,
          secondWastageRate,
          thirdWastageRate,
          fourthWastageRate,
          fifthWastageRate,
          sixthWastageRate,
          seventhWastageRate,
          dailyLogNum,
          dailyLogTime,
          dailyOldUserLogNum,
          dailyOldUserLogTime,
          ArmyCount

          ) 
                  VALUES('$everylogdate[date]',
                '$totalDayNewusers[0]',
                '$dayActivePesonrNum[0]',
                '$dayActivePesonrTime[0]',
                '$totalDayPlayTime[0]',
                '$dayPlayTime[0]',
                '$totaldayTotalTime[0]',
                '$dayTotalTime[0]',
                '$newPayPesonrNum',
                '$PayPesonrNum[0]',
                '$paytimes[0]',
                '$WeekNewPayPesonrNum[0]',
                '$weekOneLandPesonrNum',
                '$weekActivePesonrNum',
                '$weekLoyalPesonrNum',
                '$weekCorePesonrNum',
                '$weekFivePesonrNum',
                '$MonthLandTwicePesonrNum',
                '$NewFiveSeconds[0]',
                '$NewTenSeconds[0]',
                '$NewTwentySeconds[0]',
                '$NewThirtySeconds[0]',
                '$NewSixtySeconds[0]',
                '$New120Seconds[0]',
                '$New200Seconds[0]',
                '$New300Seconds[0]',
                '$New500Seconds[0]',
                '$New700Seconds[0]',
                '$New1000Seconds[0]',
                '$New1500Seconds[0]',
                '$New2000Seconds[0]',
                '$FiveSeconds[0]',
                '$TenSeconds[0]',
                '$TwentySeconds[0]',
                '$ThirtySeconds[0]',
                '$SixtySeconds[0]',
                '$_120Seconds[0]',
                '$_200Seconds[0]',
                '$_300Seconds[0]',
                '$_500Seconds[0]',
                '$_700Seconds[0]',
                '$_1000Seconds[0]',
                '$_1500Seconds[0]',
                '$_2000Seconds[0]',
                '$ThreeDayWastageRate[0]',
                '$seventhDayWastageRate[0]',
                '$TwentyDayWastageRate[0]',
                '$ThreeDayReflux',
                '$seventhDayReflux',
                '$TwentyDayReflux',
                '$iap1[0]',
                '$iap2[0]',
                '$iap3[0]',
                '$iap4[0]',
                '$iap5[0]',
                '$iap6[0]',
                '$logARPU[0]',
                '$activeARPU[0]',
                '$payARPU[0]',
                '$rechargeNum[0]',
                '$activerechargeNum[0]',
                '$TcRechargeNum[0]',
                '$TcUsedNum[0]',
                '$TcInventoryNum[0]',
                '$NewRechargeNum',
                '$level[0]',
                '$firstWastageRate[0]',
                '$secondWastageRate[0]',
                '$thirdWastageRate[0]',
                '$fourthWastageRate[0]',
                '$fifthWastageRate[0]',
                '$sixthWastageRate[0]',
                '$seventhWastageRate[0]',
                '$dailyLogNum[0]',
                '$dailyLogTime[0]',
                '$dailyOldUserLogNum[0]',
                '$dailyOldUserLogTime[0]',
                '$ArmyCount[0]'
                )";
$query= @mysql_query($sql,$db) or die(mysql_error());  

}
?>
